//
// Description: 788. 逆序对的数量
// Created by Loading on 2021/11/21.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;

constexpr int N = 100010;
int q[N], tmp[N];

LL merge_sort(int l, int r) {
    if (l >= r) {
        return 0;
    }

    int mid = l + r >> 1;
    LL res = merge_sort(l, mid) + merge_sort(mid + 1, r);
    // 归并
    int i = l, j = mid + 1, index = 0;
    while (i <= mid && j <= r) {
        if (q[i] <= q[j]) {
            tmp[index++] = q[i++];
        } else {
            tmp[index++] = q[j++];
            // 统计跨区间的逆序对数量
            res += mid - i + 1;
        }
    }
    while (i <= mid) {
        tmp[index++] = q[i++];
    }
    while (j <= r) {
        tmp[index++] = q[j++];
    }
    // 临时数组赋值回原数组
    for (i = l, j = 0; i <= r; ++i, ++j) {
        q[i] = tmp[j];
    }

    return res;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }

    LL res = merge_sort(0, n - 1);
    cout << res << endl;

    return 0;
}